clear all %clear temporary variables
close all ;%close all open figures
global Atot NAtot AMPKtot 
%set some global variables for [ATP+AMP], [NAD+NADH+NAM], and [AMPK+pAMPK]
Atot = 30;% 30e3; %[R31] TABLE3; 30mM
NAtot = 2*2;%15; %[R31] TABLE3 2mM;   %[R13] physiological intracellular NADH: 1-10uM=0.001-0.01mM   %NAM in mammalian tissues - R7 - 11~400uM
AMPKtot = 0.1;%3.2e-4mM;%20ppm - pax database, integrated whole organism
% NAtot = param(34);
%set a preliminary initial values for each variable
y0 = [ 1.0000    0.0500    0.5000    0.1000    0.1000    3.0000    1.0000    0.1000    0.1000    0.1000    1.0000    3.0000    0.0500    0.1000]; 
%initial conditions for O2 pAMPK ROS SCAV deltaH AMP HIF1a_free HIF1a_AC HIF1a_OH HIF1 NAM NAD NADH SIRT1 
[param] = getParam(3); %load initial parameters  

%% OR load specific parameters and initial conditions obtained from parameterizatioin as follows:
% load('y0andParam.mat') %param is Pbest; y0 is y0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% load('Param_Collection/06-Apr-2024 12.10.31 std_5 Svalue_7.7728.mat')
load('Param_Collection/22-Apr-2024 20.02.40 std_5 Svalue_2921.8922.mat')%SIRT oscillation
% load('Param_Collection/22-Apr-2024 19.59.07 std_5 Svalue_131.7481.mat')%
load('Param_Collection/28-Apr-2024 17.24.50 std_5 Svalue_2284.009.mat')
load('Param_Collection/28-Apr-2024 17.33.51 std_5 Svalue_266.6466.mat')%good
%  load('Param_Collection/12-May-2024 19.45.15 std_0 Svalue_1329.0444.mat')%record
  load('Param_Collection/12-May-2024 19.55.41 std_0 Svalue_1313.4073.mat')
%   load('Param_Collection/12-May-2024 20.39.18 std_0 Svalue_5974.2269.mat')%
%  load('Param_Collection/12-May-2024 20.03.09 std_0 Svalue_2721.305.mat')%record2
 
 load('Param_Collection/12-May-2024 21.12.13 std_0 Svalue_4680.373.mat')%record3 fold=1/7
%   load('Param_Collection/12-May-2024 21.24.26 std_0 Svalue_368.3084.mat')
% load('Param_Collection/12-May-2024 19.37.15 std_0 Svalue_267.627.mat')%O2 not ss
% load('Param_Collection/28-Apr-2024 20.13.23 std_5 Svalue_320.0231.mat')%ampk activator
% load('Param_Collection/28-Apr-2024 20.18.02 std_5 Svalue_378.8561.mat')%ampk activator
% load('Param_Collection/28-Apr-2024 20.34.32 std_5 Svalue_88.5646.mat')%fast
% load('Param_Collection/28-Apr-2024 20.59.55 std_0 Svalue_649.2455.mat')%best
% load('Param_Collection/11-May-2024 22.40.16 std_0.1 Svalue_481.3132.mat')
% load('Param_Collection/12-May-2024 14.04.02 std_0.1 Svalue_447.2873.mat')
% load('Param_Collection/12-May-2024 19.21.02 std_0 Svalue_2161.4944.mat')%O2 not ss



% load('y0-2.mat')
param = Pbest; 
y0=y0;
y0(1)=20;
% param(47)=param(47)*0.8; %param(48)=param(48)*0.8;
% param(18)=5.5;
% param(32)=0.02;


%% 230703 sim at different stages
% TimeOFChange = 100; %run time
TimeOfRun_norm = 300;%150;%>=50
TimeOfRun_hyp = 300;
y0_1 = y0; %the initial condition of normal situation
[tout1, yout1] = Sim(TimeOfRun_norm,param, y0_1); %simulation of normal situation

y0_2 = yout1(end,:); %the initial condition of hypoxic situation or others
%% switch different settings - hypoxia or hyperoxia
mutant = 'hypoxia1';%'HighpAMPK1';
% mutant = 'hyperoxia1';%


[param] = getMutantParam(param,mutant);
[tout2, yout2] = Sim(TimeOfRun_hyp,param, y0_2);
 yout = [yout1(1:(end-1),:); yout2];
 tout = [tout1(1:(end-1)); tout2+TimeOfRun_norm];


if strcmp(mutant,'hypoxia1')
 PlotResult2(tout, yout, 10, TimeOfRun_norm+TimeOfRun_hyp, mutant, TimeOfRun_norm, TimeOfRun_norm+30)%timecourese %lvl, lvltime1, lvltime2  'hypoxia1'
end

if strcmp(mutant,'hyperoxia1')
 PlotResult3(tout, yout, 10, TimeOfRun_norm+TimeOfRun_hyp, mutant, TimeOfRun_norm, TimeOfRun_norm+30)%timecourese %lvl, lvltime1, lvltime2  'hypoxia1'
end